//
//  WDTaskTypeServFlowView.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2024/8/29.
//

#import "WDTaskTypeServFlowView.h"
#import "WDArrivalServiceDetailModel.h"

@interface WDTaskTypeServFlowView ()

@property (nonatomic, strong) WDArrivalServiceDetailModel *taskDetailModel;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *valueLabel;


- (void)initWithTitleLabel;

- (void)initWithValueLabel;


@end

@implementation WDTaskTypeServFlowView

- (void)initWithSubView {
    self.backgroundColor = [UIColor whiteColor];
    
}

- (void)initWithTitleLabel {
    if (!_titleLabel) {
        NSString *str = @"类型状态";
        UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        float width = [str widthForFont:font] + 10;
        CGRect frame = CGRectMake(20, (self.height - 20) * 0.5, width, 20);
        _titleLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor blackColor];
            label.text = str;
        }];
    }
}

- (void)initWithValueLabel {
    if (!_valueLabel) {
        CGRect frame = self.titleLabel.frame;
        UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        frame.size.width = self.width - 20 - self.titleLabel.right - 10;
        frame.origin.x = self.width - 20 - frame.size.width;
        _valueLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#F9AD3B"];
//            label.text = str;
            label.textAlignment = NSTextAlignmentRight;
        }];
    }
    if (self.taskDetailModel) {
        NSString *str = [NSString stringWithFormat:@"%@·%@", self.taskDetailModel.taskTypeValue, self.taskDetailModel.servFlowValue];
//        if ([self.taskDetailModel.auditStatus integerValue] == 1) {
//            if (self.taskDetailModel.applyType && [self.taskDetailModel.applyType integerValue] == 0) {
//                str = @"已申请救援";
//            } else if (self.taskDetailModel.applyType && [self.taskDetailModel.applyType integerValue] == 1) {
//                str = @"已申请取消救援";
//            } else if (self.taskDetailModel.applyType && [self.taskDetailModel.applyType integerValue] == 2) {
//                str = @"已申请关闭工单";
//            }
//        }
        self.valueLabel.text = str;
    }
}

- (void)updateWithViewData:(id)data {
    
    self.taskDetailModel = data;
    
    [self initWithTitleLabel];

    [self initWithValueLabel];
}

@end
